<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  转换前：<input type="text" id="old"><br>
  <input type="button" value="转大写" onclick="deal('up')">
  <input type="button" value="转小写" onclick="deal('down')"><br>
  转换后：<input type="text" id="new">
  <script>
    // 字符串大小写转换
    function deal(opt) {
      var str = document.getElementById('old').value;
      /* switch (opt) {
        case 'up':
          str = str.toUpperCase();
          break;
        case 'down':
          str = str.toLowerCase();
          break;
      } */
      if (opt == 'up') {
        str = str.toUpperCase();
      } else if (opt == 'down') {
        str = str.toLowerCase();
      }
      document.getElementById('new').value = str;
    }
    // 封装函数，求2个数中的最大值
    /* function getMaxNum(a, b) {
      return a - b > 0 ? a : b;
    }
    var max_num = getMaxNum(45, 55);
    console.log(max_num);
    //三个数中的最大值
    function getMaxNums(a, b, c) {
      return (a - b > 0 ? a : b) - c > 0 ? (a - b > 0 ? a : b) : c;
    }
    var max_nums = getMaxNums(24, 72, 35);
    console.log(max_nums);
 */
    function getMaxNum(a,b,c){
      if(!c){
        return a - b > 0 ? a : b;
      }else if (c){
        return (a - b > 0 ? a : b) - c > 0 ? (a - b > 0 ? a : b) : c;
      }
    } 
    var max_num = getMaxNum(24, 45);
    console.log(max_num);
    var max_nums = getMaxNum(24, 72, 35);
    console.log(max_nums);
  </script>
</body>

</html>